# 启用编译数据库生成（全局生效）
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# 指定CMake的最低版本要求
cmake_minimum_required(VERSION 3.10)

# 指定项目名称和支持的语言
project(TetrisGame LANGUAGES CXX)

# 设置c++标准为c++17 
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS OFF)

# 查找ncurses 库
#find_library(CURSES_LIBRARY NAMES curses ncurses)
#find_library(NCURSES_LIBRARY NAMES ncurses)
#find_path(CURSES_INCLUDE_DIR NAMES curses.h)
find_package(Curses REQUIRED)


# 定义所有源文件
set(GAME_SOURCES
    src/main.cpp
    src/board.cpp
    src/game.cpp
    src/piece.cpp
    src/tetromino.cpp
)

# 添加可执行文件目标
add_executable(tetris ${GAME_SOURCES})

# 添加头文件路径
target_include_directories(tetris PRIVATE 
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CURSES_INCLUDE_DIR}
)

# 将ncurses库链接到可执行文件
target_link_libraries(tetris PRIVATE 
    ${CURSES_LIBRARIES}
    ${CURSES_EXTRA_LIBRARIES}
)

# 设置生成的可执行文件的输出目录
set_target_properties(tetris PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

# 打印调试信息（可选）
message(STATUS "Curses include dir: ${CURSES_INCLUDE_DIR}")
message(STATUS "Curses libraries: ${CURSES_LIBRARIES}")
message(STATUS "Extra curses libs: ${CURSES_EXTRA_LIBRARIES}")

